package com.btl.service.ai.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.btl.service.ai.auth.SecurityContextHolder;
import com.btl.service.ai.biz.constants.TaskStatusEnum;
import com.btl.service.ai.biz.entity.KwDocument;
import com.btl.service.ai.biz.mapper.KwDocumentMapper;
import com.btl.service.ai.biz.service.IKwDocumentService;
import dev.langchain4j.data.document.Document;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Tim
 * @since 2025-08-11
 */
@Service
public class KwDocumentServiceImpl extends ServiceImpl<KwDocumentMapper, KwDocument> implements IKwDocumentService {

    /**
     * 文档分页
     *
     * @param current 当前页码
     * @param size    每页数量
     * @return Page<KwDocument>
     */
    @Override
    public Page<KwDocument> page(Integer current, Integer size) {
        Long childId = SecurityContextHolder.get()
                .getChildId();
        return this.page(Page.of(current, size), new LambdaQueryWrapper<KwDocument>()
                .eq(KwDocument::getChildId, childId)
                .orderByDesc(KwDocument::getId));
    }
}
